#define _CRT_SECURE_NO_WARNINGS 1
  struct TreeNode {
 	int val;
 	struct TreeNode *left;
 	struct TreeNode *right;
 	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
  };
 
class Solution {
public:
    int _maxDepth(TreeNode* cur)
    {
        if (cur == nullptr)
        {
            return 0;
        }
        int x = _maxDepth(cur->left);
        int y = _maxDepth(cur->right);
        int max = x > y ? x : y;
        return max + 1;
    }
    int maxDepth(TreeNode* root)
    {
        return _maxDepth(root);
    }
};